package com.itcast.peft.util;

import java.util.function.Function;

public class ExceptionWrapper {

    public static <I, O> Function<I, O> wrapToRTE(FunctionWithException<I, O> funcE) {
        return i -> {
            try {
                return funcE.apply(i);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        };
    }
    
    @FunctionalInterface
    public static interface FunctionWithException<I,O> {
        
        public O apply(I in) throws Exception;
    }
}
